/**
*┌──────────────────────────────────────────────────────────────┐
*│　描    述：Manager_log                                                    
*│　作    者：NetCoreCMS                                            
*│　版    本：1.0    模板代码自动生成                                                
*│　创建时间：2019-12-25 10:52:46                             
*└──────────────────────────────────────────────────────────────┘
*┌──────────────────────────────────────────────────────────────┐
*│　命名空间： NetCoreCMS.Services                                  
*│　类    名： Manager_logService                                    
*└──────────────────────────────────────────────────────────────┘
*/
using NetCoreCMS.Common;
using NetCoreCMS.IRepository;
using NetCoreCMS.IServices;
using NetCoreCMS.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetCoreCMS.Services
{
    public class Manager_logService: IManager_logService
    {
        private readonly IManager_logRepository _repository;

        public Manager_logService(IManager_logRepository repository)
        {
            _repository = repository;
        }
        /// <summary>
        /// 增加管理日志
        /// </summary>
        /// <param name="用户id"></param>
        /// <param name="用户名"></param>
        /// <param name="操作类型"></param>
        /// <param name="备注"></param>
        /// <returns></returns>
        public int Add(int user_id, string user_name, string action_type, string remark,string ip)
        {
            Models.Manager_log manager_log_model = new Models.Manager_log();
            manager_log_model.user_id = user_id;
            manager_log_model.user_name = user_name;
            manager_log_model.action_type = action_type;
            manager_log_model.remark = remark;
            manager_log_model.user_ip = ip;
            return (int)_repository.Insert(manager_log_model);
        }
        public async Task<int?> AddAsync(int user_id, string user_name, string action_type, string remark, string ip)
        {
            Models.Manager_log manager_log_model = new Models.Manager_log();
            manager_log_model.user_id = user_id;
            manager_log_model.user_name = user_name;
            manager_log_model.action_type = action_type;
            manager_log_model.remark = remark;
            manager_log_model.user_ip = ip;
            return await _repository.InsertAsync(manager_log_model);
        }
        /// <summary>
        /// 根据用户名返回上一次登录记录
        /// </summary>
        public Models.Manager_log GetModel(string user_name, int top_num, string action_type)
        {
            return _repository.GetModel(user_name, top_num, action_type);
        }
        public async Task<Models.Manager_log> GetModelAsync(string user_name, int top_num, string action_type)
        {
            return await _repository.GetModelAsync(user_name, top_num, action_type);
        }
        public int GetCount(string conditions)
        {
            return _repository.GetCount(conditions);
        }

        public int DeleteDay(int dayCount)
        {
            return _repository.DeleteDay(dayCount);
        }

        public List<Manager_log> GetList(int pageNumber, int rowsPerPage, string conditions, string orderby, object parameters = null)
        {
            return _repository.GetListPaged(pageNumber, rowsPerPage, conditions, orderby, parameters).ToList();
        }

        public int RecordCount(string conditions, object parameters = null)
        {
            return _repository.RecordCount(conditions, parameters);
        }
    }
}